import { ref } from "vue";
import axios from 'axios'

function useURLAxios(url: string) {
  const result = ref(null)
  const loading = ref(true)
  const loaded = ref(false)
  const error = ref(null)

  axios.get(url).then((res) => {
    console.log(res, 'res');
    loaded.value = true
    loading.value = false
    result.value = res.data
  }).catch(err => {
    error.value = err
    loading.value = false
  })

  return { result, loading, loaded, error }
}

export default useURLAxios